<?php

namespace app\controller;

use app\BaseController;
use app\model\Category;
use app\model\OrdersItem;
use app\utils\simple_html_dom;
use think\App;
use think\Db;
use think\db\Where;
use think\facade\Cache;
use think\facade\View;

//require 'vendor/autoload.php';
use Firebase\JWT\JWT;


class LessonController extends BaseController
{

    var $courseModel;
    var $categoryModel;
    var $menuModel;
    var $redis;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->courseModel = new \app\model\Course();
        $this->categoryModel = new \app\model\Category();
        $this->menuModel = new \app\model\Menu();
        $this->redis = Cache::store('redis');
    }


    //查询课时关联的视频url
    public function video_url(){
        $lesson_id = $this->request->param('lessionId');
        //echo $lesson_id;
        $sql = "select *,b.type v_type from lesson a left join video b on a.video_id=b.id where a.id=:lid";
        $items = \think\facade\Db::query($sql,['lid' => $lesson_id]);
        //print_r($items);
        if (count($items)>0){
            $item = $items[0];
            $url = $item['url'];
            if ($item['v_type'] == 2) {
                $url = qq_vod_sign($url);
            }
            return json_encode(['code'=>0, 'url' => $url],JSON_UNESCAPED_UNICODE);
        }
        return '';
    }


}